package com.hospital.mapper;

import com.hospital.entity.Check;
import com.hospital.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CheckMapper {
    // 获取所有检查信息
    @Select("select * from table_checkitem")
    List<Check> getAllCheck();

    // 通过Cid获取员工信息
    @Select("select * from table_checkitem where CHECKITEM_ID = #{Ctid}")
    Check getCheckitemBycheckitem(int cid);

    // 主要方式：通过病人ID获取员工信息
    @Select("select * from table_check where PATIENT_ID = #{PID}")
    Check getCheckByPatientId(int pid);

    // 添加新检查单
    @Insert("INSERT INTO table_check" +
            "(PATIENT_ID, OFFICE_ID, EMPLOYEE_ID, " +
            "CHECK_TIME, CHECKITEM_ID)" +
            "VALUES(#{patient_id}, #{office_id}, #{employee_id}, " +
            "#{check_time}, #{checkitem_id}")
    int insertCheck(Check check);

    // 更新检查单数据
    @Update("UPDATE table_check SET PATIENT_ID=#{patient_id}," +
            "OFFICE_ID=#{office_id},EMPLOYEE_ID=#{employee_id}," +
            "CHECK_TIME=#{check_time},CHECKITEM_ID=#{checkitem_id}"
    )
    int updateCheck(Check check);



}
